#!/usr/bin/env python

import subprocess
import os
from config import KIND, APP_NAME, DEV_SERVER, DATA_DIR

APP_DIR = os.path.realpath(__file__ + "/../../" + APP_NAME)

print("Uploading %s entities to %s on %s ..." % (KIND, APP_NAME, DEV_SERVER))

# appcfg.py upload_data --application=<app-id> --kind=<kind> --filename=<data-filename> <app-directory>

if True:
    cwd = os.getcwd()
    try:
        os.chdir(DATA_DIR)
        subprocess.call([
            "appcfg.py",
            "upload_data",
            "--application=" + APP_NAME,
            "--kind=" + KIND,
            "--filename=data_" + KIND,
            "--url=" + DEV_SERVER + "/_ah/remote_api",
            "--num_threads=4",
            APP_DIR
            ])
    finally:
        os.chdir(cwd)

print("Done!")

